<div style="padding-top: 10px;">
  <% if !@category.nil? %>
    <h1 class="pagetitle"><%= link_to "All Media", :action => "list" %> &raquo; <%= @category.name %></h1>
  <% elsif !params[:tag].nil? %>
    <h1 class="pagetitle"><%= link_to "All Media", :action => "list" %> &raquo; Tag: <%= params[:tag] %></h1>
  <% elsif !params[:query].nil? %>
    <h1 class="pagetitle"><%= link_to "All Media", :action => "list" %> &raquo; Search: <%= params[:query] %></h1>
  <% elsif params[:controller] == "account" %>

  <% else %>
    <h1 class="pagetitle"><%= link_to "All Media", :action => "list" %></h1>
  <% end %>
  <% for media in @medias do %>
    <% if media.mediable_type == 'ImageFile' %>
    <div class="thumbnail-box" onclick="if (!cancelLink) document.location='<%= url_for :action => 'show', :id => media.id, :media_type => media.media_type, :permalink => media.permalink %>'">
      <div style="position: absolute; right: 5px; float: right; padding: 2px; background: #fff; border: solid 1px #cccccc;"><%= media.rating %></div>
      <div style="width: 200px; height: 200px; margin-left: auto; margin-right: auto;" class="thumbbox">
        <%= link_to_media_lightbox media.mediable.public_filename(:large), media.mediable.public_filename(:thumb) %>
        <div class='highslide-caption' style="visibility: hidden;">
          <h3 style="display: inline;"><%= link_to clean_text(media.title), :action => 'show', :id => media.id, :media_type => media.media_type, :permalink => media.permalink %>: </h3><%= clean_text(media.description) %>
        </div>
      </div>
      <%= link_to clean_text(media.title), {:action => 'show', :id => media.id, :media_type => media.media_type, :permalink => media.permalink}, {:onmouseover => 'cancelLink=true', :onmouseout => 'cancelLink=false'} %><br />
      <%= media.category.name unless media.category.nil? %><br />
      <%= link_to media.user.login, {:controller => 'account', :action => 'show', :id => media.user.login}, {:onmouseover => 'cancelLink=true', :onmouseout => 'cancelLink=false'} %> <%= distance_of_time_in_words_to_now(media.created_at) %> ago
    </div>
    <% elsif media.mediable_type == 'VideoFile' %>
    <div class="thumbnail-box" onclick="if (!cancelLink) document.location='<%= url_for :action => 'show', :id => media.id, :media_type => media.media_type, :permalink => media.permalink %>'">
      <div style="position: absolute; right: 5px; float: right; padding: 2px; background: #fff; border: solid 1px #cccccc;"><%= media.rating %></div>
      <div style="width: 200px; height: 200px; margin-left: auto; margin-right: auto;" class="thumbbox">
        <%= link_to_partial_lightbox image_tag(base_name(media.mediable.public_filename) + "-small.jpg", :style => 'border: 0;'), { :partial => "media/video", :locals => { :media => media, :secondrun => false } }, { :id => "media"+media.id.to_s } %>
        <div class='highslide-caption' style="visibility: hidden;">
          <h3 style="display: inline;"><%= link_to clean_text(media.title), :action => 'show', :id => media.id, :media_type => media.media_type, :permalink => media.permalink %>: </h3><%= clean_text(media.description) %>
        </div>
      </div>
      <%= link_to clean_text(media.title), {:action => 'show', :id => media.id, :media_type => media.media_type, :permalink => media.permalink}, {:onmouseover => 'cancelLink=true', :onmouseout => 'cancelLink=false'} %><br />
      <%= media.category.name unless media.category.nil? %><br />
      <%= link_to media.user.login, {:controller => 'account', :action => 'show', :id => media.user.login}, {:onmouseover => 'cancelLink=true', :onmouseout => 'cancelLink=false'} %> <%= distance_of_time_in_words_to_now(media.created_at) %> ago
    </div>
    <% end %>
  <% end %>
  <div class="clearer"></div>
  <div style="display: none;">
    <div id="controlbar" class="highslide-overlay controlbar">
    <a class="previous" title="Previous (left arrow key)" onclick="return hs.previous(this)" href="#"></a>
    <a class="next" title="Next (right arrow key)" onclick="return hs.next(this)" href="#"></a>
    <a class="highslide-move" title="Click and drag to move" onclick="return false" href="#"></a>
    <a class="close" title="Close" onclick="return hs.close(this)" href="#"></a>
    </div>
  </div>
</div>
